home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / MotifApp / ch11 / ColorTestWindow.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  2.0 KB  |  69 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //////////////////////////////////////////////////////////////////////////////
  3. //         This example code is from the book:
  4. //
  5. //           Object-Oriented Programming with C++ and OSF/Motif
  6. //         by
  7. //           Douglas Young
  8. //           Prentice Hall, 1992
  9. //           ISBN 0-13-630252-1    
  10. //
  11. //         Copyright 1991 by Prentice Hall
  12. //         All Rights Reserved
  13. //
  14. //  Permission to use, copy, modify, and distribute this software for 
  15. //  any purpose except publication and without fee is hereby granted, provided 
  16. //  that the above copyright notice appear in all copies of the software.
  17. ///////////////////////////////////////////////////////////////////////////////
  18. //////////////////////////////////////////////////////////////////////////////
  19.  
  20.  
  21. /////////////////////////////////////////////////////////////
  22. // ColorTestWindow.C: Test the ColorChooser dialog
  23. /////////////////////////////////////////////////////////////
  24. #include <stdio.h>
  25. #include "ColorTestWindow.h"
  26. #include "ColorChooser.h"
  27. #include <Xm/PushB.h>
  28.  
  29. Widget ColorTestWindow::createWorkArea ( Widget parent )
  30. {
  31.     _button = XtCreateWidget ( "push_to_test", 
  32.                   xmPushButtonWidgetClass,
  33.                   parent, 
  34.                   NULL, 0 );
  35.     
  36.     XtAddCallback ( _button,
  37.            XmNactivateCallback,
  38.            &ColorTestWindow::pickColorCallback,
  39.            (XtPointer) this );
  40.     
  41.     _colorChooser = new ColorChooser ( parent, "colorChooser" );
  42.     
  43.     return _button;
  44. }
  45.  
  46. void ColorTestWindow::pickColorCallback ( Widget, 
  47.                      XtPointer clientData, 
  48.                      XtPointer )
  49. {
  50.     ColorTestWindow *obj          = ( ColorTestWindow * ) clientData;
  51.     ColorChooser    *colorChooser = obj->_colorChooser;
  52.     
  53.     colorChooser->pickColor ( &ColorTestWindow::colorSelectedCallback,
  54.                  NULL,
  55.                  NULL );
  56. }
  57.  
  58. void ColorTestWindow::colorSelectedCallback ( int red, 
  59.                          int green, 
  60.                          int blue, 
  61.                          void * )
  62. {
  63.     printf ( "Color Chosen: \n\
  64. red   = %d, \n\
  65. green = %d,\n\
  66. blue  = %d\n",
  67.         red, green, blue );
  68. }
  69.